package ru.pb.game.data.xml.holders;

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import ru.pb.game.objects.model.CHANNEL;
import ru.pb.global.xml.holder.AbstractHolder;

/**
 * Хранит в себе каналы.
 * 
 * @author Felixx
 */
public final class ChannelHolder extends AbstractHolder
{
	private static ChannelHolder _instance;

	private final static TIntObjectMap<CHANNEL> _channels = new TIntObjectHashMap<CHANNEL>();

	public static ChannelHolder getInstance()
	{
		if(_instance == null)
		{
			_instance = new ChannelHolder();
		}
		return _instance;
	}

	private ChannelHolder()
	{}

	public void addChannel(CHANNEL channel)
	{
		_channels.put(channel.getId(), channel);
	}

	public static CHANNEL getChannel(int channelId)
	{
		return _channels.get(channelId);
	}

	@Override
	public int size()
	{
		return _channels.size();
	}

	@Override
	public void clear()
	{
		_channels.clear();
	}

	public static TIntObjectMap<CHANNEL> getAllChannels()
	{
		return _channels;
	}
}